<?php
require_once 'util/class.constants.php';
require_once 'service/class.noteservice.php';
require_once 'service/class.relationservice.php';

$relation = new RelationService();
$service = new NoteService();

// 1. test public note with no followees
// $result = $service->publishNote(1, '哈哈，发出了第一条微博了。', 'pic1.jpg_120_240_pic2.jpg_300_400', array(1), 0, 0);

// 2. test public note with followees
// $relation->createFollowRelation(2, 1);
// $relation->createFollowRelation(3, 1);
// $relation->createFollowRelation(4, 1);

// $result = $service->publishNote(1, '哈哈，发出了第四条微博了。', 'pic7.jpg_120_240_pic8.jpg_300_400', array(1), 0, 0);
// echo json_encode($result);

// 3. test forward note with no followees
// $result = $service->forwardNote(5, "恭喜啊，总算发出了一条微博了", 10, 1, 0, 0);
// echo json_encode($result);

// 4. test forward note with followees
// $relation->createFollowRelation(2, 5);
// $relation->createFollowRelation(3, 5);
// $result = $service->forwardNote(5, "评论第四条微博", 12, 1, 0, 0);
// echo json_encode($result);

// 5. test comment note
// $result=$service->commentNote(5, "comment第四条微博", 1, 12, 0, 0);
// echo json_encode($result);

// 6. test like note
// $result=$service->likeNote(5, 1, 12, 0, 0);
// echo json_encode($result);

// 7. test send private message
// $result = $service->sendPrivateMessage(5, 1, "hello, 你好！", 0, 0);
// echo json_encode($result);

// 8. test read private message list
// for($i=0; $i<10; $i++) {
// 	$service->sendPrivateMessage(6, 7, "hello, 你好！".$i, 0, 0);
// 	sleep(1);
// 	$service->sendPrivateMessage(7, 6, "re:hello, 你好！".$i, 0, 0);
// 	sleep(1);
// }
$result = $service->getPrivateMessages(6, 1, 110);
echo json_encode($result);

// 9. test read friend time line
// for($i=330; $i<350; $i++) {
// 	$service->publishNote(1, '哈哈，发出了第'.$i.'条微博了。', 'pic'.$i.'.jpg_120_240_pic'.($i+100).'.jpg_300_400', array($i % 2), 0, 0);
// 	sleep(1);
// }
// $result = $service->getFriendsTimeline(2, 1, 90);
// echo json_encode($result);

// 10. test get user plubic time line
// $result = $service->getUserPublicTimeline(1, 6, 0, 0);
// $result = $service->getUserPublicTimeline(1, 6, 1, 90);
// $result = $service->getUserPublicTimeline(5, 6, 0, 0);
// echo json_encode($result);

// 11. test get user all time line
// $result = $service->getUserAllTimeline(5, 0, 0);
// $result = $service->getUserAllTimeline(5, 1, 1325404204);
// echo json_encode($result);

// 12. test get comments for note
// $result = $service->getNoteComments(12, 0, 0);
// $result = $service->getNoteComments(12, 1, 1);
// echo json_encode($result);